package com.ysd.lis.controller.qi;

import com.ysd.common.Result;
import com.ysd.lis.annotation.LogDetail;
import com.ysd.lis.aspect.OperationType;
import com.ysd.lis.entity.qi.QiIndexItem;
import com.ysd.lis.entity.qi.QiIndexItemFilter;
import com.ysd.lis.service.qi.QiQiIndexItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: server_lis
 * @author: liuQi
 * @create: 2024-01-29 17:02
 */
@Api(tags = "指标报表字段")
@RestController
@RequestMapping("/api/qi/reportFiled")
public class QiReportFiledsController {

    @Autowired
    QiQiIndexItemService qiQiIndexItemService;

    @ApiOperation("获取指标报表字段列表")
    @GetMapping("/getQiIndexItemList/{indexCode}")
    public Result getQiIndexItemList(@PathVariable("indexCode") String indexCode) {
        return qiQiIndexItemService.getQiIndexItemList(indexCode);
    }

    @ApiOperation("通过专业编码获取指标细项")
    @GetMapping("/getQiIndexItemListByMajorCode/{majorCode}")
    public Result getQiIndexItemListByMajorCode(@PathVariable("majorCode") String majorCode) {
        return qiQiIndexItemService.getQiIndexItemListByMajorCode(majorCode);
    }
    @ApiOperation("通过专业编码获取过滤指标细项")
    @GetMapping("/getQiIndexItemFilterListByMajorCode/{majorCode}")
    public Result getQiIndexItemFilterListByMajorCode(@PathVariable("majorCode") String majorCode) {
        return qiQiIndexItemService.getQiIndexItemFilterListByMajorCode(majorCode);
    }

    @ApiOperation("添加过滤指标细项")
    @PostMapping("/addQiIndexItemFilter")
    public Result addQiIndexItemFilter(@RequestBody QiIndexItemFilter qiIndexItemFilter) {
        return qiQiIndexItemService.addQiIndexItemFilter(qiIndexItemFilter);
    }
    @ApiOperation("删除过滤指标细项")
    @PostMapping("/deleteQiIndexItemFilter")
    public Result deleteQiIndexItemFilter(@RequestBody QiIndexItemFilter qiIndexItemFilter) {
        return qiQiIndexItemService.deleteQiIndexItemFilter(qiIndexItemFilter);
    }

    @ApiOperation("同步指标数据")
    @PostMapping("/syncQiIndexItemData")
    public Result syncQiIndexItemData(@RequestBody List<QiIndexItem> qiIndexItems) {
        return qiQiIndexItemService.syncQiIndexItemData(qiIndexItems);
    }

    @ApiOperation("添加质量指标项目")
    @PostMapping("/addQiIndexItem")
    @LogDetail(requestParam ="addQiIndexItem",operationType = OperationType.INSERT, module = "添加质量指标项目",content = "增加【itemName】指标项目", businessName = "itemName")
    public Result addQiIndexItem(@RequestBody QiIndexItem qiIndexItem) {
        return qiQiIndexItemService.addQiIndexItem(qiIndexItem);
    }

    @ApiOperation("编辑质量指标项目")
    @PostMapping("/updateQiIndexItem")
    @LogDetail(requestParam ="updateQiIndexItem",operationType = OperationType.UPDATE, module = "编辑质量指标项目",content = "编辑【itemName】指标项目", businessName = "itemName")
    public Result updateQiIndexItem(@RequestBody QiIndexItem qiIndexItem) {
        return qiQiIndexItemService.updateQiIndexItem(qiIndexItem);
    }

    @ApiOperation("删除质量指标项目")
    @PostMapping("/deleteQiIndexItem")
    @LogDetail(requestParam ="deleteQiIndexItem",operationType = OperationType.DELETE, module = "删除质量指标项目",content = "删除【itemName】指标项目", businessName = "itemName")
    public Result deleteQiIndexItem(@RequestBody QiIndexItem qiIndexItem) {
        return qiQiIndexItemService.deleteQiIndexItem(qiIndexItem);
    }
}
